package com.example.mylibrary;

import static android.content.ContentValues.TAG;

import android.app.Instrumentation;
import android.util.Log;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject2;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class Register {
    public static Instrumentation instrumentation=null;
    public static UiDevice device=null;
    @Before
    public void initInstrumentation() throws InterruptedException {
        Log.i(TAG,"连接设备");
        instrumentation=
                InstrumentationRegistry.getInstrumentation();
        device=UiDevice.getInstance(instrumentation);
        device.pressHome();
        Thread.sleep(1000);
        UiObject2 icon1=device.findObject
                (By.text("CashBook"));
        icon1.click();
        Thread.sleep(3000);
    }

    //    注册
    @Test
    private void Register() throws InterruptedException {
        device.findObject(By.res("com.lyc.cashbook:id/register")).click();
        Thread.sleep(1000);
        device.findObject(By.res("com.lyc.cashbook:id/et_account")).setText("Lizeyu");
        Thread.sleep(1000);
        device.findObject(By.res("com.lyc.cashbook:id/et_psw")).setText("1");
        Thread.sleep(1000);
        device.findObject(By.res("com.lyc.cashbook:id/et_psw_again")).setText("1");
        Thread.sleep(1000);
        device.findObject(By.res("com.lyc.cashbook:id/register")).click();
    }

    @After
    public static void quite(){
        device.pressBack();
    }

}
